#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

CONF="3proxy"
PROG="/usr/bin/3proxy"

start_service() {
	config_load "$CONF"

	local enabled conffile

	config_get_bool enabled "config" "enabled" "0"
	[ "$enabled" -eq "1" ] || return 0

	config_get conffile "config" "conffile" "/etc/3proxy/3proxy.cfg"

	procd_open_instance
	procd_set_param command "$PROG" "$conffile"

	procd_set_param stdout "1"
	procd_set_param stderr "1"
	procd_set_param limits core="unlimited"
	procd_set_param limits nofile="1000000 1000000"
	procd_set_param respawn

	procd_close_instance
}

service_triggers() {
	procd_add_reload_trigger "$CONF"
}
